package com.ruoyi.web.controller.mobile;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mobile.domain.LessonPointPrescription;
import com.ruoyi.mobile.model.bo.LessonPointPrescriptionBo;
import com.ruoyi.mobile.model.request.LessonPointPrescriptionRequest;
import com.ruoyi.mobile.service.ILessonPointPrescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * 指定分数运动处方配置Controller
 * 
 * @author ruoyi
 * @date 2023-01-10
 */
@RestController
@RequestMapping("/mobile/pointprescription")
public class LessonPointPrescriptionController extends BaseController
{
    @Autowired
    private ILessonPointPrescriptionService lessonPointPrescriptionService;

    /**
     * 查询指定分数运动处方配置列表
     */
    @PreAuthorize("@ss.hasPermi('mobile:pointprescription:list')")
    @GetMapping("/list")
    public TableDataInfo list(LessonPointPrescription lessonPointPrescription)
    {
        startPage();
        List<LessonPointPrescriptionBo> list = lessonPointPrescriptionService.selectLessonPointPrescriptionList(lessonPointPrescription);
        return getDataTable(list);
    }

    /**
     * 获取指定分数运动处方配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('mobile:pointprescription:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(lessonPointPrescriptionService.selectLessonPointPrescriptionById(id));
    }

    /**
     * 新增指定分数运动处方配置
     */
    @PreAuthorize("@ss.hasPermi('mobile:pointprescription:add')")
    @Log(title = "指定分数运动处方配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LessonPointPrescriptionRequest lessonPointPrescriptionRequest)
    {
        return toAjax(lessonPointPrescriptionService.insertLessonPointPrescription(lessonPointPrescriptionRequest));
    }

    /**
     * 修改指定分数运动处方配置
     */
    @PreAuthorize("@ss.hasPermi('mobile:pointprescription:edit')")
    @Log(title = "指定分数运动处方配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LessonPointPrescriptionRequest lessonPointPrescriptionRequest)
    {
        return toAjax(lessonPointPrescriptionService.updateLessonPointPrescription(lessonPointPrescriptionRequest));
    }

    /**
     * 删除指定分数运动处方配置
     */
    @PreAuthorize("@ss.hasPermi('mobile:pointprescription:remove')")
    @Log(title = "指定分数运动处方配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(lessonPointPrescriptionService.deleteLessonPointPrescriptionByIds(ids));
    }


    /**
     * 获取指定分数运动处方配置详细信息
     */
    @GetMapping(value = "/point/{point}")
    public AjaxResult getInfo(@PathVariable("point") BigDecimal point)
    {
        return AjaxResult.success(lessonPointPrescriptionService.selectLessonPointPrescriptionByPoint(point));
    }


    /**
     * 获取所有指定分数的运动处方的分数
     * @return
     */
    @GetMapping(value = "/all")
    public AjaxResult getAllPoint() {
        return AjaxResult.success(lessonPointPrescriptionService.selectAllLessonPoint());
    }

}
